﻿@model CurrencyModel

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)

<div class="content">
    <div class="form-horizontal">
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-body">
                    @(Html.LocalizedEditor<CurrencyModel, CurrencyLocalizedModel>("currency-info-localized",
                          @<div>
                              <div class="form-group">
                                  <div class="col-md-3">
                                      @Html.SDFLabelFor(model => model.Locales[item].Name)
                                  </div>
                                  <div class="col-md-9">
                                      @Html.SDFEditorFor(model => model.Locales[item].Name)
                                      @Html.ValidationMessageFor(model => model.Locales[item].Name)
                                  </div>
                              </div>
                              @Html.HiddenFor(model => model.Locales[item].LanguageId)
                          </div>
                          ,
                        @<div>
                              <div class="form-group">
                                  <div class="col-md-3">
                                      @Html.SDFLabelFor(model => model.Name)
                                  </div>
                                  <div class="col-md-9">
                                      @Html.SDFEditorFor(model => model.Name)
                                      @Html.ValidationMessageFor(model => model.Name)
                                  </div>
                              </div>
                          </div>
                          ))
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CurrencyCode)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.CurrencyCode)
                            @Html.ValidationMessageFor(model => model.CurrencyCode)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Rate)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Rate)
                            @Html.ValidationMessageFor(model => model.Rate)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DisplayLocale)
                        </div>
                        <div class="col-md-9">
                            @{
                                var cultures = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.SpecificCultures)
                                    .OrderBy(x => x.EnglishName)
                                    .Select(x => new SelectListItem
                                    {
                                        Value = x.IetfLanguageTag,
                                        Text = string.Format("{0}. {1}", x.EnglishName, x.IetfLanguageTag)
                                    })
                                    .ToList();
                                cultures.Insert(0, new SelectListItem
                                {
                                    Value = "",
                                    Text = @T("Admin.Configuration.Currencies.Fields.DisplayLocale.Select").Text
                                });
                            }
                            @Html.SDFDropDownListFor(model => model.DisplayLocale, cultures)
                            @Html.ValidationMessageFor(model => model.DisplayLocale)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.CustomFormatting)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.CustomFormatting)
                            @Html.ValidationMessageFor(model => model.CustomFormatting)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.SelectedProjectIds)
                        </div>
                        <div class="col-md-9">
                            <div class="row">
                                <div class="col-md-4">
                                    @Html.EditorFor(model => model.SelectedProjectIds, new {SelectList = Model.AvailableProjects})
                                    <script>
                                        $(document).ready(function() {
                                            var projectsIdsInput = $('#@Html.FieldIdFor(model => model.SelectedProjectIds)').data("kendoMultiSelect");
                                            projectsIdsInput.setOptions({
                                                autoClose: false
                                            });

                                            @if (Model.AvailableProjects.Count == 0)
                                            {
                                                <text>
                                    projectsIdsInput.setOptions({
                                        enable: false,
                                        placeholder: 'No Projects available'
                                    });
                                    projectsIdsInput._placeholder();
                                    projectsIdsInput._enable();
                                    </text>
                                            }
                                        });
                                    </script>
                                </div>
                                <div class="col-md-8">
                                    @Html.Action("MultiprojectDisabledWarning", "Common")
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.Published)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.Published)
                            @Html.ValidationMessageFor(model => model.Published)
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-3">
                            @Html.SDFLabelFor(model => model.DisplayOrder)
                        </div>
                        <div class="col-md-9">
                            @Html.SDFEditorFor(model => model.DisplayOrder)
                            @Html.ValidationMessageFor(model => model.DisplayOrder)
                        </div>
                    </div>
                    @if (Model.Id > 0)
                    {
                        <div class="form-group">
                            <div class="col-md-3">
                                @Html.SDFLabelFor(model => model.CreatedOn)
                            </div>
                            <div class="col-md-9">
                                @Html.SDFDisplayFor(model => model.CreatedOn)
                            </div>
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
</div>